<?php 
namespace lib;

class GlobalState {
    private static $instance = null;
    private $state = [];

    private function __construct() {}
    private function __clone() {}

    // 获取单例实例
    public static function getInstance() {
        if (self::$instance === null) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    // 设置全局变量
    public function set($key, $value) {
        $this->state[$key] = $value;
    }

    // 获取全局变量
    public function get($key) {
        return $this->state[$key] ?? null;
    }
}


?>